﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Collections.Specialized.BitVector32;

namespace YiMeiJiaLibModel.Config
{
    public static class ApiConf
    {

        public static string AppName = "壹家甄选";
        public static string Host = "https://tl-api.奇怪的域名.top";
        public static string DeveloperHost = "https://tl-api2.奇怪的域名.top";
        public static string CND = "https://kb.cdn.奇怪的域名.vip/wwwroot";
        public static string Static = "https://tl-api.奇怪的域名.top/static";
        public static string DeveloperStatic = "https://tl-api2.奇怪的域名.top/static";
        public static Dictionary<string, string> Action = new Dictionary<string, string>()
        {
            { "smsLogin","/api/User/SmsLogin,post"} , // 短信验证码登录
            {"sendSms","/api/User/SendSms,post" }  // 发送短信
            ,{ "GetAllCategories","/api/Good/GetAllCategories,post"}  // 获取所有商品分类栏目数据
            ,{ "获取随机推荐商品","/api/Good/GetGoodsRecommendList,post"}  //获取随机推荐商品
            ,{ "获取商品详情","/api/Good/GetDetial,post"}  //商品详情
            ,{ "获取用户信息","/api/User/GetUserInfo,post"}  //获取用户信息
            ,{ "根据查询条件获取分页数据","/api/Good/GetGoodsPageList,post"} // 根据查询条件获取分页数据
            ,{"获取用户收货地址列表","/api/User/GetUserShip,post" } // 获取收获地址列表
            ,{ "保存收获地址","/api/User/SaveUserShip,post"}
             ,{ "获取游戏列表",$"{ApiStatic()}/games/list.txt,get"}
            ,{ "获取协议-用户协议",$"{ApiStatic()}/data/用户协议.txt,get"}
            ,{ "获取协议-隐私协议",$"{ApiStatic()}/data/隐私保护政策.txt,get"}
        };

        /// <summary>
        /// 获取api的static文件资源
        /// </summary>
        /// <returns></returns>
        public static string ApiStatic()
        {
#if DEBUG
            return DeveloperStatic;
#endif
            return Static;
        }

        /// <summary>
        /// 获取api 地址
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public static string Api(string action,bool? selfHost = false)
        {
            if (! Convert.ToBoolean(selfHost))
            {
#if DEBUG
                return $"{DeveloperHost}{ApiConf.Action[action]}";
#endif
                return $"{Host}{ApiConf.Action[action]}";
            }
            else
            {
                return ApiConf.Action[action];
            }

        }
    }
}
